//
//  MainViewController.m
//  ShiHuo
//
//  Created by zhiyou on 16-4-11.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "MainViewController.h"
#import "HomeVC.h"
#import "HaiTaoVC.h"
#import "ShaiWuVC.h"
#import "FindVC.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden = NO;
    self.navigationItem.hidesBackButton = YES;
    self.view.backgroundColor = [UIColor whiteColor];    
    
    [self createTabBar];
}
- (void)createTabBar {
    
    HomeVC *vc1 = [[HomeVC alloc] init];
    vc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"主页" image:[UIImage imageNamed:@"btn_home_normal"] selectedImage:nil];
    
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:vc1];
    
    HaiTaoVC *vc2 = [[HaiTaoVC alloc] init];
    vc2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"海淘" image:[UIImage imageNamed:@"btn_live_normal"] selectedImage:nil];
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:vc2];
    
    ShaiWuVC *vc3 = [[ShaiWuVC alloc] init];
    vc3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"晒物" image:[UIImage imageNamed:@"btn_vdo_gif"] selectedImage:nil];
    UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:vc3];
    
    FindVC *vc4 = [[FindVC alloc] init];
    vc4.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现" image:[UIImage imageNamed:@"btn_vdo_face"] selectedImage:nil];
    UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:vc4];
    
    MyVC *vc5 = [[MyVC alloc] init];
    vc5.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:[UIImage imageNamed:@"btn_user_normal"] selectedImage:nil];
    UINavigationController *nav5 = [[UINavigationController alloc] initWithRootViewController:vc5];
    
    UITabBarController *tabbarVC = [[UITabBarController alloc] init];
    NSArray *arr = @[nav1,nav2,nav3,nav4,nav5];
    tabbarVC.viewControllers = arr;
    
    //更改tabbar的背景颜色
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 49)];
    bgView.backgroundColor = [UIColor blackColor];
    [tabbarVC.tabBar insertSubview:bgView atIndex:0];
    tabbarVC.tabBar.opaque = YES;
    
    
    UIWindow *window = [UIApplication sharedApplication].delegate.window;
    window.rootViewController = tabbarVC;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
